package com.FOD.fragments;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.FOD.clases.R;
import com.FOD.entities.EmpleadoHorario;
import com.FOD.entities.User;
import com.FOD.util.SessionDBHandler;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ViewProfileEmployeFragment extends Fragment{
	View rootView;
	TextView nickname_view;
	TextView name_view;
	TextView mail_view;
	TextView age_view;
	TextView sex_view;
	TextView dependency_view;
	TextView sport_view;
	TextView phone_view;
	TextView create_date_view;
	TextView hour_in_view;
	TextView hour_out_view;
	SessionDBHandler db;
	User mUser = new User();
	EmpleadoHorario mEmploye = new EmpleadoHorario();

	public ViewProfileEmployeFragment() {
	}

	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		rootView = inflater.inflate(R.layout.view_profile_employe, container, false);
		db = new SessionDBHandler(rootView.getContext());

		nickname_view = (TextView)rootView.findViewById(R.id.nickname_view);
		name_view = (TextView)rootView.findViewById(R.id.name_view);
		mail_view = (TextView)rootView.findViewById(R.id.mail_view);
		age_view = (TextView)rootView.findViewById(R.id.age_view);
		sex_view = (TextView)rootView.findViewById(R.id.sex_view);
		dependency_view = (TextView)rootView.findViewById(R.id.dependency_view);
		sport_view = (TextView)rootView.findViewById(R.id.sport_view);
		phone_view = (TextView)rootView.findViewById(R.id.phone_view);
		create_date_view = (TextView)rootView.findViewById(R.id.create_date_view);
		hour_in_view = (TextView)rootView.findViewById(R.id.hour_in_view);
		hour_out_view = (TextView)rootView.findViewById(R.id.hour_out_view);

		mUser = db.getUserDetails();
		nickname_view.setText("Nickname: "+mUser.getNickname());
		name_view.setText("Nombre: "+mUser.getName());
		mail_view.setText("Correo: "+mUser.getMail());
		age_view.setText("Edad: "+String.valueOf(mUser.getAge()));
		sex_view.setText("Sexo: "+mUser.getConverterSexToString(mUser.getSex(), rootView.getContext()));
		dependency_view.setText("Dependencia: "+mUser.getDependecy());
		sport_view.setText("Deporte: "+mUser.getSport());
		phone_view.setText("Telefono: "+String.valueOf(mUser.getPhone()));

		SimpleDateFormat dt = new SimpleDateFormat("yyyyy-mm-dd"); 
		Date date;
		try {
			date = dt.parse(mUser.getCreateDate().toString());
			create_date_view.setText("Fecha de alta: "+String.valueOf(date.toString()));
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 

		mEmploye = db.getScheduleEmployeDetails();
		hour_in_view.setText("Hora de entrada: "+mEmploye.getInicio());
		hour_out_view.setText("Hora de salida: "+mEmploye.getH_final());

		return rootView;
	}

}
